import React from "react";
import axios from "axios";
import Link from "next/link";
export default function BlogList(props: any) {
  const { posts } = props;
  return (
    <>
      <ul>
        {posts.map((item: any) => (
          <li key={item.id}>
            <Link
              href={{
                pathname: "/blog/[id]",
                query: { id: item.id },
              }}
            >
              {item.username}
            </Link>
          </li>
        ))}
      </ul>
    </>
  );
}
export async function getStaticProps() {
  const list = await fetch("https://jsonplaceholder.typicode.com/users");
  console.log(list);
  const data = await list.json();
  return {
    props: {
      posts: data,
    },
  };
}
